package com.sgb.goods.widget.pop.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.sgb.goods.BR;
import com.sgb.goods.R;
import com.sgb.goods.entity.order.OrderPayDetailEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class PopPayInfoDetailAdapter extends BaseRecycleAdapter<OrderPayDetailEntity> {


    public PopPayInfoDetailAdapter(Context context, List<OrderPayDetailEntity> data) {
        super(context, R.layout.goods_pop_item_pay_info_detail, data);
    }

    @Override
    public void convert(ItemViewHolder holder, OrderPayDetailEntity detailEntity) {
        holder.setBinding(BR.entity, detailEntity);
        if (holder.getLayoutPosition() == datas.size() - 1) {
            holder.setVisible(R.id.last_line, true);
        } else {
            holder.setVisible(R.id.last_line, false);
        }
        if (holder.getLayoutPosition() == 0) {
            holder.getView(R.id.line2).setVisibility(View.INVISIBLE);
        } else {
            holder.getView(R.id.line2).setVisibility(View.VISIBLE);
        }

        TextView tv_pay_time = holder.getView(R.id.tv_pay_time);
        TextView pay_num = holder.getView(R.id.pay_num);
        TextView order_money = holder.getView(R.id.order_money);
        TextView payment_method = holder.getView(R.id.payment_method);
        TextView pay_status = holder.getView(R.id.pay_status);
        tv_pay_time.setText(TextUtils.isEmpty(detailEntity.payApplyTime) ? "" : detailEntity.payApplyTime);
        pay_num.setText(detailEntity.id);
        String money = "¥" + detailEntity.money;
        order_money.setText(money);
        payment_method.setText("在线付款".equals(detailEntity.method) ? "网银支付" : "银行转账");
        String payStatus = "";
        if (0 == detailEntity.payState) {
            payStatus = "待付款";
            pay_status.setTextColor(context.getResources().getColor(R.color.color_EF4033));
        } else if (1 == detailEntity.payState) {
            payStatus = "冻结中";
            pay_status.setTextColor(context.getResources().getColor(R.color.color_EF4033));
        } else if (2 == detailEntity.payState) {
            if ("线下付款".equals(detailEntity.method)) {
                payStatus = "付款成功";
            } else {
                payStatus = "已成功";
            }
            pay_status.setTextColor(context.getResources().getColor(R.color.color_06C764));
        } else if (3 == detailEntity.payState) {
            payStatus = "支付失败";
            pay_status.setTextColor(context.getResources().getColor(R.color.color_EF4033));
        } else if (4 == detailEntity.payState) {
            payStatus = "确认中";
            pay_status.setTextColor(context.getResources().getColor(R.color.color_EF4033));
        } else if (5 == detailEntity.payState) {
            payStatus = "审批中";
            pay_status.setTextColor(context.getResources().getColor(R.color.color_EF4033));
        } else if (6 == detailEntity.payState) {
            payStatus = "已拒绝";
            pay_status.setTextColor(context.getResources().getColor(R.color.color_EF4033));
        } else if (50 == detailEntity.payState) {
            payStatus = "付款中";
            pay_status.setTextColor(context.getResources().getColor(R.color.goods_color_FF5792FD));
        } else if (60 == detailEntity.payState) {
            payStatus = "已撤销";
            pay_status.setTextColor(context.getResources().getColor(R.color.goods_color_FF969696));
        }
        pay_status.setText(payStatus);
    }
}
